<?php 

class Settings extends CI_Controller {

	function __construct()
	{
		parent::__construct();
		/* $this->load->model('staff_model'); */
	}
	
	function index()
	{	
		if($this->session->userdata('logged_in_jtk'))
		{
			$session_data = $this->session->userdata('logged_in_jtk');
			$data['title'] = "";
			$data['menu'] = 5;
			$data['act'] = 'konf_sms_setting_device';
			//$this->load->view('header_view', $data);   
			$this->load->view('header_view');
			$this->load->view('settings_view', $data);
		}
		else
		{
			//If no session, redirect to login page
			//redirect('home', 'refresh');
			//$data['username'] = "teu login";
			$data['username'] = "";
			$data['menu'] = 0;
			$data['login'] = 0;
			$this->load->view('home_view', $data);
		}		
	}
	
	function konf_sms_setting_device()
	{
		$data['title'] = "Setting Device!";
		$data['menu'] = 5;
		$data['act'] = 'konf_sms_setting_device';
		$this->load->view('header_view');
		$this->load->view('settings_view', $data);
	}
	
	function konf_sms_test_koneksi_device()
	{
		$data['title'] = "Test Koneksi Device";
		$data['menu'] = 5;
		$data['act'] = 'konf_sms_test_koneksi_device';
		$this->load->view('header_view');
		$this->load->view('settings_view', $data);
	}
	
	function konf_sms_konfigurasi_smsdrc()
	{
		$data['title'] = "Setting Konfigurasi SMSDRC";
		$data['menu'] = 5;
		$data['act'] = 'konf_sms_konfigurasi_smsdrc';
		$this->load->view('header_view');
		$this->load->view('settings_view', $data);
	}
	function konf_sms_install_service_sms()
	{
		$data['title'] = "Install Service SMS";
		$data['menu'] = 5;
		$data['act'] = 'konf_sms_install_service_sms';
		$this->load->view('header_view');
		$this->load->view('settings_view', $data);
	}
	
	function konf_sms_run_service_sms()
	{
		$data['title'] = "Menjalankan Service SMS";
		$data['menu'] = 5;
		$data['act'] = 'konf_sms_run_service_sms';
		$this->load->view('header_view');
		$this->load->view('settings_view', $data);
	}
	
	function konf_sms_stop_service_sms()
	{
		$data['title'] = "Menghentikan Service SMS";
		$data['menu'] = 5;
		$data['act'] = 'konf_sms_stop_service_sms';
		$this->load->view('header_view');
		$this->load->view('settings_view', $data);
	}
	
	function insert(){
		$data = array(
			'nip' => $this->input->post('nip'), 
			'kode_dosen' => $this->input->post('kode_dosen'), 
			'nama' => $this->input->post('nama'), 
			'hp' => $this->input->post('hp'),
			'email' => $this->input->post('email')
		);
		$this->staff_model->tambah($data);
		redirect('staff');
	}
	
	function edit()
	{
		$nip = $this->uri->segment(3);
		$data['title'] = "Edit Data Staff";
		$data['menu'] = 2;
		$data['act'] = 'edit';
		$data['data_edit'] = $this->staff_model->per_id($nip);
		$this->load->view('staff_view',$data);
	}
	
	function update()
	{
		$nip = $this->input->post('nip');
		$data = array(			
			'nama' => $this->input->post('nama'), 
			'kode_dosen' => $this->input->post('kode_dosen'),
			'hp' => $this->input->post('hp'),
			'email' => $this->input->post('email')
		);
		$this->staff_model->update($nip,$data);		
		redirect('staff');
	}
	
	function hapus()
	{
		$nip = $this->uri->segment(3);
		$this->staff_model->hapus($nip);				
		redirect('staff');
	}
}

?>